package com.ktgj.flight.controller;

import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.web.page.TableDataInfo;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.flight.domain.FlightAdjustPassenger;
import com.ktgj.flight.service.IFlightAdjustPassengerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 机票大客户白名单Controller
 * 
 * @author ruoyi
 * @date 2021-11-10
 */
@ControllerAdvice
@RestController
@RequestMapping("/passenger")
public class FlightAdjustPassengerController extends BaseController
{
    @Autowired
    private IFlightAdjustPassengerService flightAdjustPassengerService;

    /**
     * 查询机票大客户白名单列表
     */
    //@PreAuthorize(hasPermi = "flight:passenger:list")
    @GetMapping("/list")
    public TableDataInfo list(FlightAdjustPassenger flightAdjustPassenger)
    {
        startPage();
        List<FlightAdjustPassenger> list = flightAdjustPassengerService.selectFlightAdjustPassengerList(flightAdjustPassenger);
        return getDataTable(list);
    }

    /**
     * 导出机票大客户白名单列表
     */
    //@PreAuthorize(hasPermi = "flight:passenger:export")
    @Log(title = "机票大客户白名单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlightAdjustPassenger flightAdjustPassenger) throws IOException
    {
        List<FlightAdjustPassenger> list = flightAdjustPassengerService.selectFlightAdjustPassengerList(flightAdjustPassenger);
        ExcelUtil<FlightAdjustPassenger> util = new ExcelUtil<FlightAdjustPassenger>(FlightAdjustPassenger.class);
        util.exportExcel(response, list, "机票大客户白名单数据");
    }

    /**
     * 获取机票大客户白名单详细信息
     */
    //@PreAuthorize(hasPermi = "flight:passenger:query")
    @GetMapping(value = "/{pId}")
    public AjaxResult getInfo(@PathVariable("pId") Long pId)
    {
        return AjaxResult.success(flightAdjustPassengerService.selectFlightAdjustPassengerById(pId));
    }

    /**
     * 新增机票大客户白名单
     */
    //@PreAuthorize(hasPermi = "flight:passenger:add")
    @Log(title = "机票大客户白名单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlightAdjustPassenger flightAdjustPassenger)
    {
        return toAjax(flightAdjustPassengerService.insertFlightAdjustPassenger(flightAdjustPassenger));
    }

    /**
     * 修改机票大客户白名单
     */
    //@PreAuthorize(hasPermi = "flight:passenger:edit")
    @Log(title = "机票大客户白名单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlightAdjustPassenger flightAdjustPassenger)
    {
        return toAjax(flightAdjustPassengerService.updateFlightAdjustPassenger(flightAdjustPassenger));
    }

    /**
     * 删除机票大客户白名单
     */
    //@PreAuthorize(hasPermi = "flight:passenger:remove")
    @Log(title = "机票大客户白名单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pIds}")
    public AjaxResult remove(@PathVariable Long[] pIds) {
        return toAjax(flightAdjustPassengerService.deleteFlightAdjustPassengerByIds(pIds));
    }

}
